package br.com.sysprova.view;

import java.awt.EventQueue;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class TelaSelecaoCadastro {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TelaSelecaoCadastro window = new TelaSelecaoCadastro();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public TelaSelecaoCadastro() {
		initialize();
	}
	
	public Point centralizarFrame (){   
        Rectangle r = frame.getBounds();  
      // Dimensoes da janela  
        int widthSplash = r.width ;  
        int heightSplash = r.height; 
		
		return ( new Point (((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth()/2) - (widthSplash/2),  
	            			((int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()/2) - (heightSplash/2))
			   );  
	} 

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 449, 194);
		frame.setTitle("SysProva");
		frame.setAlwaysOnTop(true);
		frame.setLocation(centralizarFrame());
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		frame.setVisible(true);
		
		JLabel lblSelcCadastro = new JLabel("Qual tipo de cadastro deseja realizar?");
		lblSelcCadastro.setFont(new Font("SketchFlow Print", Font.BOLD, 18));
		lblSelcCadastro.setBounds(10, 29, 413, 32);
		frame.getContentPane().add(lblSelcCadastro);
		
		JButton btnSelecAluno = new JButton("Aluno");
		btnSelecAluno.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				selecionarAluno();
			}
		});
		btnSelecAluno.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnSelecAluno.setBounds(33, 91, 89, 23);
		frame.getContentPane().add(btnSelecAluno);
		
		JButton btnSelecProfessor = new JButton("Professor");
		btnSelecProfessor.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				selecionarProfessor();
			}
		});
		btnSelecProfessor.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnSelecProfessor.setBounds(280, 91, 121, 23);
		frame.getContentPane().add(btnSelecProfessor);
	}
	private void selecionarAluno(){
		TelaCadastroAluno selecAluno  = new TelaCadastroAluno();
		frame.dispose();
	}
	private void selecionarProfessor(){
		TelaCadastroProfessor selecProfessor  = new TelaCadastroProfessor();
		frame.dispose();
	}
}
